package com.harry12.mybatis.controller;

import com.harry12.mybatis.Mapper.BlogMapper;
import com.harry12.mybatis.entity.Blog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

@RestController
public class BlogController {
    @Resource
    BlogMapper blogMapper;

    @GetMapping("/blog")
    public String queryBlog(){
        HashMap hashMap = new HashMap();
        hashMap.put("author","harry");
        List<Blog> blogs = blogMapper.queryBlogIF(hashMap);
        for(Blog blog:blogs){
            System.out.println(blog);
        }
        return "query if";

    }
    @RequestMapping("/updateBlog")
    public String updateBlog(){
        HashMap hashMap = new HashMap();
        hashMap.put("id",2);
      //  hashMap.put("title","apple");
        hashMap.put("author","9527888jerry");
        blogMapper.updateBlog(hashMap);
        return "update set";
    }
}
